package com.zh.note.huawei.twohundred.购物车;

import java.util.*;

/**
 * @Author: zhanghuan
 * @date: 2023/8/27 21:38
 * @description: create it
 */
public class Main {

    public static void main(String[] args) {
        // Scanner sc = new Scanner(System.in);
        // int num = sc.nextInt();
        // int maxCount = sc.nextInt();
        int num = 3;
        int maxCount = 7;
        // sc.nextLine();
        // String inputs = sc.nextLine();
        String inputs = "1 10 100";
        String[] s = inputs.split(" ");
        List<Integer> values = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            values.add(Integer.parseInt(s[i]));
        }
        Collections.sort(values);
        PriorityQueue<Item> priorityQueue = new PriorityQueue<>((o1, o2) -> o1.curTotal - o2.curTotal);
        priorityQueue.add(new Item(0, 0, values.get(0)));
        while (!priorityQueue.isEmpty() && maxCount > 0) {
            Item cur = priorityQueue.poll();
            System.out.println(cur.curTotal);
            maxCount--;
            if (cur.idx < num - 1) {
                priorityQueue.add(new Item(cur.preTotal, cur.idx + 1, cur.preTotal + values.get(cur.idx + 1)));
                priorityQueue.add(new Item(cur.curTotal, cur.idx + 1, cur.curTotal + values.get(cur.idx + 1)));
            }
        }
    }

    static class Item {
        int preTotal;
        int idx;
        int curTotal;

        public Item(int total, int idx, int next) {
            this.preTotal = total;
            this.idx = idx;
            this.curTotal = next;
        }

    }
}
